package com.ruoyi.merchant.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.merchant.mapper.MerchantImgsMapper;
import com.ruoyi.merchant.domain.MerchantImgs;
import com.ruoyi.merchant.service.IMerchantImgsService;

/**
 * imgsService业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-16
 */
@Service
public class MerchantImgsServiceImpl implements IMerchantImgsService 
{
    @Autowired
    private MerchantImgsMapper merchantImgsMapper;

    /**
     * 查询imgs
     * 
     * @param id imgs主键
     * @return imgs
     */
    @Override
    public MerchantImgs selectMerchantImgsById(Long id)
    {
        return merchantImgsMapper.selectMerchantImgsById(id);
    }

    /**
     * 查询imgs列表
     * 
     * @param merchantImgs imgs
     * @return imgs
     */
    @Override
    public List<MerchantImgs> selectMerchantImgsList(MerchantImgs merchantImgs)
    {
        return merchantImgsMapper.selectMerchantImgsList(merchantImgs);
    }

    /**
     * 新增imgs
     * 
     * @param merchantImgs imgs
     * @return 结果
     */
    @Override
    public int insertMerchantImgs(MerchantImgs merchantImgs)
    {
        return merchantImgsMapper.insertMerchantImgs(merchantImgs);
    }

    /**
     * 修改imgs
     * 
     * @param merchantImgs imgs
     * @return 结果
     */
    @Override
    public boolean updateMerchantImgs(MerchantImgs[] merchantImgs)
    {
        merchantImgsMapper.deleteMerchantImgsByMerchantId(merchantImgs[0].getMid());
        for (MerchantImgs merchantImg : merchantImgs) {
            merchantImgsMapper.insertMerchantImgs(merchantImg);
        }
        return true;
    }

    @Override
    public int updateMerchantImgs(MerchantImgs merchantImgs) {
        return merchantImgsMapper.updateMerchantImgs(merchantImgs) ;
    }

    /**
     * 批量删除imgs
     * 
     * @param ids 需要删除的imgs主键
     * @return 结果
     */
    @Override
    public int deleteMerchantImgsByIds(Long[] ids)
    {
        return merchantImgsMapper.deleteMerchantImgsByIds(ids);
    }

    /**
     * 删除imgs信息
     * 
     * @param id imgs主键
     * @return 结果
     */
    @Override
    public int deleteMerchantImgsById(Long id)
    {
        return merchantImgsMapper.deleteMerchantImgsById(id);
    }

    @Override
    public List<MerchantImgs> selectMerchantImgsByMerchantId(Long merchantId) {
        return merchantImgsMapper.selectMerchantImgsByMerchantId(merchantId);
    }

}
